package com.zcn.io.web.config;

import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.github.benmanes.caffeine.cache.Cache;

import java.util.concurrent.TimeUnit;

@Configuration
public class CacheConfig {

    @Bean
    public Cache<String, Object> caffeineCache() {
        return Caffeine.newBuilder()
                .expireAfterWrite(60 * 12, TimeUnit.MINUTES) // 设置写入后10分钟自动过期
                .maximumSize(100) // 设置缓存的最大条数
                .build();
    }
}
